package com.annhoa.infrastructure.security.handle;

import com.alibaba.fastjson.JSON;
import com.annhoa.infrastructure.common.AjaxResult;
import com.annhoa.infrastructure.util.ServletUtils;
import org.apache.http.HttpStatus;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义退出处理类 返回成功
 *
 * @author ruoyi
 */
@Configuration
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {


    /**
     * 退出处理
     *
     * @return
     */
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        //logout do something
        ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(HttpStatus.SC_OK, "退出成功")));
    }

}
